﻿using Gaf;

using Microsoft.Extensions.DependencyInjection;

ServiceCollection services = new();
services.AddSingleton<Demo1, Demo1>();
var serviceProvider = services.BuildServiceProvider();
var demo1 = serviceProvider.GetRequiredService<Demo1>();

services.AddSingleton<Demo2, Demo2>();

var serviceProvider2 = services.BuildServiceProvider();
var demo1_2 = serviceProvider.GetRequiredService<Demo1>();

var isSame = demo1 == demo1_2;
Console.WriteLine(isSame);

//1. 创建插件框架
var gaf = GafManager.Create();
var addinManager = gaf.AddinManager;

//3. 配置安装插件

gaf.Configure(services);
addinManager.Addins.ToList().ForEach(x => Console.WriteLine(x));

//4. 启动框架
serviceProvider = services.BuildServiceProvider();
var gaf2 = serviceProvider.GetRequiredService<IGaf>();
Console.WriteLine(gaf == gaf2);
Console.WriteLine(gaf.AddinManager == serviceProvider.GetRequiredService(typeof(IAddinManager)));



gaf.Start(serviceProvider);
addinManager.Addins.ToList().ForEach(x => Console.WriteLine(x));


//关闭框架
gaf.Shutdown();
addinManager.Addins.ToList().ForEach(x => Console.WriteLine(x));


public class Demo1
{

}

public class Demo2
{

}